using System.Xml;

/// <summary>
/// Summary description for SQObject
/// </summary>
public class SQObject
{
    string _id;
    string _dataType;
    string _hasToolTip;
    string _questionid;
    string _type;

    XmlNode configuration;

    string getAttribute(string attributeName)
    {
        if (configuration.Attributes[attributeName] != null)
            return configuration.Attributes[attributeName].Value;
        else
            return null;
    }

    public string ID { get { return _id; } }
    public string DataType { get { return _dataType; } }
    public string Type { get { return _type; } }
    public string HasToolTip { get { return _hasToolTip; } }
    public string QuestionId { get { return _questionid;} }
    public XmlNode Tab { get { return configuration.SelectSingleNode("ancestor::tab"); } }
    public XmlNode Section { get { return configuration.SelectSingleNode("ancestor::section"); } }
    public XmlNode Facility { get { return configuration.SelectSingleNode("ancestor::facility"); } }

    public SQObject(XmlNode configuration)
	{
        this.configuration = configuration;
        // required!
        _id = configuration.Attributes["id"].Value;
        _type = configuration.Attributes["type"].Value;
        // optional
        _dataType = getAttribute("datatype");
        _hasToolTip = getAttribute("tooltip");
        _questionid = getAttribute("questionid");
    }
}
